package top.majuan.lianxi.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.majuan.lianxi.base.PageBean;
import top.majuan.lianxi.base.R;
import top.majuan.lianxi.entity.TbBillboard;
import top.majuan.lianxi.service.TbBilloardService;
import top.majuan.lianxi.vo.PageVo;

@RestController
@RequestMapping("/billboard")
@RequiredArgsConstructor
public class TbBilloardController {
    public final TbBilloardService tbBillboardService;
@PostMapping
   public R<String> insert(@RequestBody TbBillboard tbBillboard)
   {
       return tbBillboardService.insert(tbBillboard);
   }
    @GetMapping("/{id}")
    public R<TbBillboard> queryByid(@PathVariable("id") Integer id) {
        return tbBillboardService.queryByid(id);
    }
    @PutMapping("")
    public R<String> update(@RequestBody TbBillboard tbBillboard) {
        return tbBillboardService.update(tbBillboard);
    }
    @DeleteMapping("/{id}")
    public R<String> delete(@PathVariable("id") Integer id) {
        return tbBillboardService.delete(id);
    }

    @GetMapping("/{pn}/{ps}")
    public R<PageVo<TbBillboard>> queryPage(@PathVariable("pn") Long pageNumber, @PathVariable("ps") Long pageSize, TbBillboard tbBillboard) {
        return tbBillboardService.queryPage(PageBean.instance(pageNumber, pageSize), tbBillboard);
    }
}
